Professional Swift by Michael Dippery

Professional Swift by Michael Dippery

Author:Michael Dippery [Dippery, Michael]
Language: eng
Format: azw3
ISBN: 9781119148715
Publisher: Wiley
Published: 2015-05-08T00:00:00+00:00


Finally, the method closes with three lines of code that dismiss the dialog sheet, so users won’t have to force-quit the application. These three lines of code also reload the table view so new data will appear immediately:

NSApp.endSheet(panel) panel.orderOut(sender) tableView.reloadData()

These lines are identical to what you would find in an Objective-C application, save for being written in Swift’s, instead of Objective-C’s, syntax.

Hooking Up the Dialog Sheet

Now, you have to hook up the dialog sheet’s OK button to this action. Switch back to MainMenu .xib and Control-drag a connection from the panel’s OK button to the createBirthday() outlet you just created in your AppDelegate class.

Build and run the Birthdays application again. You should now have a fully functional dialog sheet. You can invoke it by selecting New from the File menu and enter a new birthday. This time, clicking OK will actually dismiss the sheet!



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.